
function varargout=dataPrep(y,hp,low,high,K)

Datav           = y;
%Datal           = flipud(log(Datav)); %For flipping the data upside down
Datal           = log(Datav);

%% Diff-filter

Dataf       = diff(Datal);
for i=1:size(Datal,2)
    Dataf(:,i) = Dataf(:,i)-mean(Dataf(:,i));
    Dataf(:,i) = Dataf(:,i)/std(Dataf(:,i));
end

%% HP-filter
[Data_trend, Data_cyc]  =   hpfilter(Datal,hp);
Datah       =   Data_cyc;


for i=1:size(Datah,2)
    Datah(:,i) = Datah(:,i)-mean(Datah(:,i));
    Datah(:,i) = Datah(:,i)/std(Datah(:,i));
end


%% Modified Baxter-King-filter

Datab       = bpfm(Datal,low,high,K);
Datab_trend = Datal - Datab;

for i=1:size(Datab,2)
    Datab(:,i) = Datab(:,i)-mean(Datab(:,i));
    Datab(:,i) = Datab(:,i)/std(Datab(:,i));
end

%% Christiano-Fitzegerald-filter

Datacf      = bpass(Datal,high,low);
Datacf_trend= Datal - Datacf;

for i=1:size(Datacf,2)
    Datacf(:,i) = Datacf(:,i)-mean(Datacf(:,i));
    Datacf(:,i) = Datacf(:,i)/std(Datacf(:,i));
end

varargout(1) = {Datah};
varargout(2) = {Dataf};
varargout(3) = {Datacf};
varargout(4) = {Datab};
varargout(5) = {Datav};
varargout(6) = {Datal};
varargout(7) = {Data_trend};
varargout(8) = {Datab_trend};
varargout(9) = {Datacf_trend};

%plot_filtered_series(Dataf,Datab,Datah,Datacf)